<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>{% block title %}{% endblock %} </title>
    
    <script type="text/javascript" src="/hocabul/static/script/jquery.js"></script>
    <!-- 
    <script type="text/javascript" src="script/jquery.idTabs.css"></script>
     --> 
    <link rel="stylesheet" href="http://yui.yahooapis.com/2.7.0/build/reset-fonts-grids/reset-fonts-grids.css" type="text/css">
    <link rel="stylesheet" href="/hocabul/static/css/styles.css" type="text/css">
<script type="text/javascript" charset="utf-8">

var course_edits = {
		add_course: function(user_id, course_id) {
			console.log("add_course, uid: " + user_id +  ", cid: " + course_id); 
			$.ajax({
		  	  url: user_id + '/add/course/' + course_id,
		  	  success: function(data) {
						course = course_edits.json_data(data);
			  	  var course_list = document.getElementById('course_list');
						$(course_list).append($('<li>').val("c" + course.id).text(course.name));
		      },
		  		fail: function(data) {
								alert("failed");
		      }
		  });
	  },
	  
	  delete_course: function(user_id, course_id) {
        $.ajax({
        	  url: user_id + '/delete/' + course_id,
        	  success: function(data) {
							el = document.getElementById('c'+course_id)
            	el.parentNode.removeChild(el);
            },
        		fail: function(data) {
							alert("failed")
            }
        });
    },

    display_courses: function(department_id) {
    	$.ajax({
      	  url: "/hocabul/department/" + department_id + "/courses",
      	  success: function(data) {
    					var select = document.getElementById('course_selector'); 
							$(select).empty()
							data = eval(data);
							for(var entry in data) {
    						$(select).append($('<option>').text(data[entry].name).val(data[entry].id));
							}
          },
      		fail: function(data) {
							alert("failed")
          }
      });
    },

    get_course_selection: function() {
    	var select = document.getElementById('course_selector');
    	return (select.options[select.selectedIndex].value); 
    },

    json_data:function(str) {
        return eval('(' + str + ')');
    }
}
</script>
	{% block extrahead %}{% endblock %}
</head>

<body class="app_body">
    <div id="doc" class="yui-t7"> 
    <div id="hd" class="banner" role="banner">
    	<h1>Header</h1>
    	<div id="global-nav">
           <a href="/hocabul/profile/" >Profile</a>|
           <a href="/hocabul/courses/" >Courses</a>|
           <a href="/hocabul/search/" >Search</a>|
           <a href="/hocabul/logout/" class="">Logout</a>
    	</div>
    </div> 
     
	    <div class="yui-g"> 
				{% block body %}{% endblock %}
	    </div> 
	 
	     
	   <div id="ft" class="banner" role="banner">
		    <div id="global-nav">
           <a href="/about/" class="about">About</a>
         |
           <a href="/about/comments/" class="comment-help">Comment help</a>
         |
           <a href="/contact/" class="contact">Contact us</a>
         |
           <a href="/errata/" class="errata">Errata</a>
         |
           <a href="http://www.amazon.com/gp/product/1590597257?ie=UTF8&amp;tag=djangoproject-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1590597257" class="buy">
               Buy the print version on Amazon.com</a>
    		</div>
		 </div>
	</div> 
</body>
</html>